#include <stdio.h>

#define TRACE(x...) x
#define PRINT(x...) TRACE(printf(x))

#define rep(i,n) for (int i=0; i<n; i++)

int n, m;
int grid[110][110];
int d[4][2] = {{1,0}, {0,1}, {-1,0}, {0, -1}};
bool vis[110][110];
bool pat;
int M, min;

void DFS(int x, int y, int s) {
	if (vis[x][y]) return;
	if (pat) return;
	if (grid[x][y]==M) {
		pat=true; return;
	}

	vis[x][y]=true;

	if (x) if (grid[x-1][y] - grid[x][y] == s) DFS(x-1, y, s);
	if (y) if (grid[x][y-1] - grid[x][y] == s) DFS(x, y-1, s);
	if ((x+1)<n) if (grid[x+1][y] - grid[x][y] == s) DFS(x+1, y, s);
	if ((y+1)<m) if (grid[x][y+1] - grid[x][y] == s) DFS(x, y+1, s);
}

int main() {
	while (1) {
		scanf("%d %d", &n, &m);

		if (n==-1 && m==-1) break;

		rep(i,n) rep(j,m) scanf("%d", &grid[i][j]);
	
		min=4000000;
		M=-1;

//		PRINT("%d %d", n, m);

		rep(i,n) rep(j,m) if (min>grid[i][j]) min=grid[i][j];
		rep(i,n) rep(j,m) if (M<grid[i][j]) M=grid[i][j];

		if (min==M) {
			printf("At least one pattern exists.\n");
			continue;
		}

		rep(i,n) rep(j,m) vis[i][j]=false;

		pat=false;

		rep(i,n) {
			rep(j,m) {
				if (grid[i][j]==min) {
					if (i) 	DFS(i-1,j, grid[i-1][j] - grid[i][j]);
					if (j) 	DFS(i,j-1, grid[i][j-1] - grid[i][j]);
					if ((i+1)<n) 	DFS(i+1,j, grid[i+1][j] - grid[i][j]);
					if ((j+1)<m) 	DFS(i,j+1, grid[i][j+1] - grid[i][j]);
				}
			}
		}

		if (pat) printf("At least one pattern exists.\n");
		else printf("No pattern can be found.\n");		
	}

	return 0;
}
